<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <body>

        <ui:composition template="./templates/basicTemplate.xhtml">
            <ui:define name="content">
                    <h:form id="new_ticket">                                        
                        <p:panelGrid columns="2">
                            <f:facet name="header">
                                <h:outputText value="Nový ticket"/>                        
                            </f:facet> 
                            <h:outputLabel value="Nadpis:" for="title" />
                            <p:inputText validatorMessage="Prosím vyplňte nadpis (minimálně 5 znaků, maximálně 40 znaků)" id="title" value="#{newTicketForm.title}" required="true">
                                <f:validateLength minimum="5" maximum="40"/>
                            </p:inputText>

                            <h:outputLabel value="Kategorie" for="category" />
                            <p:selectOneMenu value="#{newTicketForm.category}" id="category" required="true">
                                <f:selectItems value="#{category.categories}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat.id}"/>                            
                            </p:selectOneMenu>


                            <h:outputLabel value="Obsah: " for="content" />
                            <p:editor validatorMessage="Prosím vyplňte obsah ticketu" id="content" value="#{newTicketForm.content}">
                                <f:validateRequired/>
                            </p:editor>

                            <f:facet name="footer">
                                <p:commandButton value="Uložit ticket" action="#{newTicketForm.saveTicket()}" update="new_ticket"/>
                            </f:facet>
                        </p:panelGrid>
                    </h:form>    
            </ui:define>

        </ui:composition>

    </body>
</html>
